var t = require("../../../../@babel/runtime/helpers/typeof"), a = getApp(), e = "plugin.store-cashier.frontend.boss.center.getChildStoreList";

Page({
    data: {
        language: "",
        shop_info: {},
        shop_amount: {},
        bossId: 0,
        shopListArr: [],
        loading: !1,
        allLoaded: !1,
        goload: !0,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        this.checkrouter(), this.getChainShopInfo();
    },
    checkrouter: function() {
        try {
            var a = function() {
                for (var t = wx.getStorageSync("yz_basic_info"), a = t.popularize_page.mini.vue_route, e = 0; e < a.length; e++) if ("ChainShopIndex" == a[e]) return console.log(t.popularize_page.mini.mini_url + "跳转的路径"), 
                wx.showToast({
                    title: "未开启推广权限",
                    duration: 1e3,
                    icon: "none",
                    success: function() {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: t.popularize_page.mini.mini_url
                            });
                        }, 1e3);
                    }
                }), {
                    v: void 0
                };
            }();
            if ("object" === t(a)) return a.v;
        } catch (t) {
            console.log(t);
        }
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.isLoadMore ? this.getMoreShopList() : wx.showToast({
            title: "没有更多数据",
            icon: "none"
        });
    },
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    gotoIncome: function() {
        var t = a.getNetAddresss("member.member.withdrawByMobile");
        a._getNetWork({
            url: t,
            success: function(t) {
                var a = t.data;
                1 === a.result ? 1 == a.data.is_bind_mobile ? wx.navigateTo({
                    url: "/packageA/member/withdrawEditmobile/withdrawEditmobile"
                }) : wx.navigateTo({
                    url: "/packageA/member/withdrawal/withdrawal"
                }) : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getChainShopInfo: function() {
        var t = this, e = a.getNetAddresss("plugin.store-cashier.frontend.boss.center.index");
        a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 === e.result ? (t.setData({
                    shop_info: e.data.store_boss.has_one_member,
                    shop_amount: e.data.statistics,
                    bossId: e.data.store_boss.id
                }), t.getShopList(t.data.bossId)) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1500,
                    success: function() {
                        setTimeout(function() {
                            wx.navigateBack({
                                delta: 1
                            });
                        }, 1500);
                    }
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getShopList: function(t) {
        var o = this, i = a.getNetAddresss(e);
        i += "&page=" + this.data.page + "&boss_id=" + t, a._getNetWork({
            url: i,
            success: function(t) {
                var a = t.data;
                1 === a.result ? o.setData({
                    total_page: a.data.last_page,
                    shopListArr: a.data.data
                }) : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreShopList: function() {
        var t = this;
        if (this.data.page != this.data.total_page) if (this.data.page >= this.data.total_page) this.setData({
            loading: !0,
            allLoaded: !0
        }); else {
            var o = this.data.page + 1;
            this.setData({
                page: o
            });
            var i = a.getNetAddresss(e);
            i += "&page=" + this.data.page + "&boss_id=" + this.data.bossId, a._getNetWork({
                url: i,
                success: function(a) {
                    var e = a.data;
                    if (1 === e.result) {
                        var o = t.data.shopListArr.concat(e.data.data);
                        t.setData({
                            loading: !1,
                            allLoaded: !1,
                            shopListArr: o
                        });
                    } else {
                        var i = t.data.page - 1;
                        t.setData({
                            page: i,
                            loading: !0,
                            allLoaded: !0,
                            isLoadMore: !1
                        });
                    }
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    goToShop: function(t) {
        var a = t.currentTarget.dataset.id || t.target.dataset.id;
        wx.navigateTo({
            url: "/packageB/member/chain_shop/ChainShopInfo/ChainShopInfo?id=" + a
        });
    }
});